package web.filter;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

/**
 * 对于编码问题封装的request对象
 * @author gongkai
 *
 */
public class EncodingRequest extends HttpServletRequestWrapper {
	private String encode="utf-8";
	public EncodingRequest(HttpServletRequest request,String encode) {
		super(request);
		if(encode!=null){
			this.encode=encode;
		}
	}

	@Override
	public String getParameter(String name) {
		try {
			return new String(super.getParameter(name).getBytes("ISO-8859-1"),encode);
		} catch (UnsupportedEncodingException e) {
e.printStackTrace();
			return null;
		}
	}
	
	

}
